package com.qfedu.openplateform.manager.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.qfedu.openplateform.manager.dao.TokenMapper;
import com.qfedu.openplateform.manager.entity.UserToken;
import com.qfedu.openplateform.manager.service.TokenService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional
public class TokenServiceImpl  implements TokenService {

    @Autowired
    private TokenMapper tokenMapper;

    /**
     * token管理----->查询所有token
     * @param token
     * @param page
     * @param pageSize
     * @return
     */
    @Override
    public PageInfo<UserToken> getTokenList(UserToken token, Integer page, Integer pageSize) {
        PageHelper.startPage(page, pageSize);
        return new PageInfo<>(tokenMapper.getTokenList(token));
    }

    /**
     * token管理----->删除token
     * @param ids
     */
    @Override
    public void deleteToken(int[] ids) {
        for (int id : ids) {
            tokenMapper.deleteTokenById(id);
        }
    }

    /**
     * token管理----->更新token
     * @param userToken
     */
    @Override
    public void updateToken(UserToken userToken) {
        tokenMapper.updateToken(userToken);
    }
}
